Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downloadable attachment option (as mentioned in the changelog per 2023-07-27) #286

Merged

Conversation

robindirksen1
Copy link
Contributor

Add downloadable attachment option (as mentioned in the changelog per 2023-07-27) for the entities:

  • estimates
  • external sales invoice
  • sales invoice
  • document: general document
  • document: general journal document
  • document: purchase invoice
  • document: receipt
  • document: typeless document

For example, get info and content from an attachment added to a SalesInvoice:

// Create the Moneybird client
$connection = connect($redirectUrl, $clientId, $clientSecret);
$connection->setAdministrationId($administrationId);
$moneybird = new \Picqer\Financials\Moneybird\Moneybird($connection);

// Get the sales invoices from our administration
$salesInvoice = $moneybird->salesInvoice()->find(394429746230855571);

foreach ($salesInvoice->attachments as $salesInvoiceAttachment) {
    var_dump($salesInvoiceAttachment); // dumps the API response object
    var_dump($salesInvoiceAttachment->download()); // returns the string of the file
}

In the background, when you call the download endpoint, you'll be redirected to a temporary URL that contains the file content.

From the API docs:

Download the attachment. The response will be a redirect to a temporarily available URL where the attachment can be downloaded. Use the Location header in the response to download the attachment.

… 2023-07-27) for the entities:

- estimates
- external sales invoice
- sales invoice
- document: general document
- document: general journal document
- document: purchase invoice
- document: receipt
- document: typeless document
@robindirksen1
Copy link
Contributor Author

@sanderlissenburg, can you also ping Stephan for checking this PR?

@stephangroen stephangroen merged commit c21978a into picqer:main Aug 14, 2023
@robindirksen1
Copy link
Contributor Author

Thanks @stephangroen !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants